// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.utils;

import java.util.Arrays;

public class IntHyperCube2 {
    private static final long serialVersionUID = 1L;
    private final int width;
    private final int height;
    private final int depth;
    private final int quanta;
    private final int wxh;
    private final int wxhxd;
    private final int[][][][] value;

    public IntHyperCube2(int _width, int _height, int _depth, int _quanta) {
        this.width = _width;
        this.height = _height;
        this.depth = _depth;
        this.quanta = _quanta;
        this.wxh = _width * _height;
        this.wxhxd = this.wxh * _depth;
        this.value = new int[_width][_height][_depth][_quanta];
    }

    public void clear() {
        Arrays.fill(this.value, 0);
    }

    public void fill(int newValue) {
        Arrays.fill(this.value, newValue);
    }

    private int getIndex(int int2, int int3, int int1, int int0) {
        return int2 >= 0 && int3 >= 0 && int1 >= 0 && int0 >= 0 && int2 < this.width && int3 < this.height && int1 < this.depth && int0 < this.quanta
            ? int2 + int3 * this.width + int1 * this.wxh + int0 * this.wxhxd
            : -1;
    }

    public int getValue(int x, int y, int z, int w) {
        return x >= 0 && y >= 0 && z >= 0 && w >= 0 && x < this.width && y < this.height && z < this.depth && w < this.quanta ? this.value[x][y][z][w] : 0;
    }

    public void setValue(int x, int y, int z, int w, int newValue) {
        this.value[x][y][z][w] = newValue;
    }

    public final int getWidth() {
        return this.width;
    }

    public final int getHeight() {
        return this.height;
    }

    public final int getDepth() {
        return this.depth;
    }

    public final int getQuanta() {
        return this.quanta;
    }
}
